<template>
	<view class="container">
		<view class="headerNav" style="background-color: #fff;">
			<!-- <u-navbar title="" placeholder :border-bottom="false"></u-navbar> -->
		</view>
		<view class="Steps">
			<view class="toptext">
				<text>{{data.topText}}</text>
			</view>
			<u-steps :list="data.numList" active-color="#00D075" :current="data.current" mode="number"></u-steps>
		</view>
		<view class="from">
			<u-form :model="data.formData" :error-type="['toast','message']" ref="form1">
				<!-- 基本信息 -->
				<view v-if="!data.StepsShow">
					<u-form-item required label="职位名称" prop="basic.jobname" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-field :placeholder-style="data.placeholderStyle" :border-bottom="false" label-width="0"
								v-model="data.formData.basic.jobname" placeholder="请填写职业名称,'如销售员'"  />
						</view>
					</u-form-item>
					<u-form-item required label="招聘类型" prop="basic.nature_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.nature_text"
								:placeholder-style="data.placeholderStyle" placeholder="请选择要求" disabled
								@click="data.isnature=true" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="data.isnature=true"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label=" 职位描述" prop="basic.content" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input height="0" maxlength="500" type="textarea" style="width:100%;"
								v-model="data.formData.basic.content" :placeholder-style="data.placeholderStyle"
								placeholder="介绍工作内容/职位要求/加分项" :auto-height="true" disabled @click="tocontent" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="tocontent"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label="职位类型" prop="basic.category_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input style="width:100%;" v-model="data.formData.basic.category_text"
								:placeholder-style="data.placeholderStyle" placeholder="请选择职位信息对应的职位分类" disabled
								@click="tocategoryName" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="tocategoryName"></u-icon>
						</view>
					</u-form-item>
					<u-form-item label="岗位福利" prop="basic.tag_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input height="0" type="textarea" style="width: 100%;"
								v-model="data.formData.basic.tag_text" :placeholder-style="data.placeholderStyle"
								placeholder="请选择岗位福利,最多可添加10个" disabled @click="tag" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="tag"></u-icon>
						</view>
					</u-form-item>
				</view>
				<!-- 职位要求 -->
				<view class="jobAsk" v-if="data.StepsShow">
					<u-form-item required label="经验要求" prop="basic.experience_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.experience_text"
								:placeholder-style="data.placeholderStyle" placeholder="请选择要求" disabled
								@click="data.isexperience=true" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40"
								@click="data.isexperience=true"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label="最低学历" prop="basic.education_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.education_text"
								:placeholder-style="data.placeholderStyle" placeholder="请选择要求" disabled
								@click="data.iseducation=true" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40"
								@click="data.iseducation=true"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label="薪资范围" prop="basic.wage_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.wage_text" :placeholder-style="data.placeholderStyle"
								placeholder="请选择要求" disabled @click="data.isWage=true" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="data.isWage=true"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label="年龄要求" prop="basic.age_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.age_text" :placeholder-style="data.placeholderStyle"
								placeholder="请选择要求" disabled @click="data.isage=true" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="data.isage=true"></u-icon>
						</view>
					</u-form-item>
					<u-form-item required label="部门" prop="basic.department" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-field :placeholder-style="data.placeholderStyle" :border-bottom="false" label-width="0"
								v-model="data.formData.basic.department" placeholder="请填写部门"  />
						</view>
					</u-form-item>
					<u-form-item required label="招聘人数" prop="basic.amount_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-field @input="amountChange" :placeholder-style="data.placeholderStyle"
								:border-bottom="false" label-width="0" v-model="data.formData.basic.amount_text"
								placeholder="请填写招聘人数"  />
						</view>
					</u-form-item>
					<u-form-item required label="工作地区" prop="basic.district_text" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input v-model="data.formData.basic.district_text"
								:placeholder-style="data.placeholderStyle" placeholder="请选择要求" disabled
								@click="getShow" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="getShow"></u-icon>
						</view>
					</u-form-item>
					<u-form-item label="详细地区" prop="basic.address" label-position="top">
						<view class="u-flex u-flex-1 u-row-between">
							<u-input style="width: 100%;" v-model="data.formData.basic.address"
								:placeholder-style="data.placeholderStyle" placeholder="请选择要求" disabled
								@click="toaddress" />
							<u-icon name="arrow-right" color="#bbbbbb" size="40" @click="toaddress"></u-icon>
						</view>
					</u-form-item>
					<!-- 联系方式 -->
					<u-form-item style="position: relative;" required label="联系方式"
						prop="contact.use_company_contact_text" label-position="top">
						<view style="display: flex;justify-content:space-between;">
							<u-input style="width: 650rpx;" disabled @click="data.sheetShow = true"
								v-model="data.formData.contact.use_company_contact_text" placeholder="请选择"
								:placeholder-style="data.placeholderStyle" />
							<view
								style="width: calc(100% - 400rpx);display: flex;align-items: center;position: absolute;top: 20rpx;right: 0;">
								<text style="margin-right: 10rpx;">联系方式保密</text>
								<u-switch @change="checked" size="40" activeColor="#00D075" v-model="data.checked"></u-switch>
							</view>
							<u-icon name="arrow-right" color="#bbbbbb" size="40"
								@click="data.sheetShow = true"></u-icon>
						</view>
					</u-form-item>
					<!-- 使用其他联系方式 -->
					<view v-if="data.isuse_company_contact">
						<u-form-item required label="联系人" prop="contact.contact" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.contact" placeholder="请填写联系人"
									 />
							</view>
						</u-form-item>
						<u-form-item required label="联系电话" prop="contact.mobile" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field type="number" :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.mobile" placeholder="请填写联系电话"
									 />
							</view>
						</u-form-item>
						<u-form-item label="联系微信" prop="contact.weixin" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.weixin" placeholder="请填写联系微信"
									 />
							</view>
						</u-form-item>
						<u-form-item label="联系固话" prop="contact.telephone" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field type="number" :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.telephone" placeholder="请填写联系固话"
									 />
							</view>
						</u-form-item>
						<u-form-item label="联系邮箱" prop="contact.email" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.email" placeholder="请填写联系邮箱"
									 />
							</view>
						</u-form-item>
						<u-form-item label="联系QQ" prop="contact.qq" label-position="top">
							<view class="u-flex u-flex-1 u-row-between">
								<u-field type="number" :placeholder-style="data.placeholderStyle" :border-bottom="false"
									label-width="0" v-model="data.formData.contact.qq" placeholder="请填写联QQ"
									 />
							</view>
						</u-form-item>
					</view>
				</view>
			</u-form>
		</view>
		<u-bottom-button @cancel='getfrist' :showCancelButton="data.StepsShow" cancelText="上一步"
			:confirmText="data.confirmText" @confirm="submit"></u-bottom-button>
		<!--  招聘类型 -->
		<u-picker v-model="data.isnature" @confirm="natureConfirm" range-key="name" mode="selector"
			:range="data.natureList" :default-selector="data.defaultIndex" ></u-picker>
		<!-- 经验要求 -->
		<u-picker v-model="data.isexperience" @confirm="experienceConfirm" range-key="name" mode="selector"
			:range="data.experiencelist" :default-selector="data.defaultExp" ></u-picker>
		<!-- 最低学历 -->
		<u-picker v-model="data.iseducation" @confirm="educationConfirm" range-key="name" mode="selector"
			:range="data.educationlist" :default-selector="data.defaultEdu" ></u-picker>
		<!-- 薪资范围 -->
		<u-picker-salary v-model="data.isWage" :minwage="data.formData.basic.minwage"
			:maxwage="data.formData.basic.maxwage" @cancel="data.isWage = false" @close="data.isWage = false"
			@confirm="wageConfirm"></u-picker-salary>
		<!-- 年龄范围 -->
		<u-picker-age v-model="data.isage" :minwage="data.formData.basic.minage" :maxwage="data.formData.basic.maxage"
			@cancel="data.isage = false" @close="data.isage = false" @confirm="ageConfirm"></u-picker-age>
		<!-- 选择地区 -->
		<u-popup v-model="data.idcitycategory" mode="bottom" height="70%">
			<view class="poplist">
				<view class="botList" v-for="(item,index) in data.citycategory" :key="index"
					:class="data.isId == item.value? 'active':''" @tap="leftClick(item.value,item.children,item.label)">
					<text>{{item.label}}</text>
					<u-icon name="arrow-right" v-if="item.children.length>0"
						:color="data.isId == item.value? '#00D075':'#867F7F'" size="28"></u-icon>
				</view>
			</view>
		</u-popup>
		<u-popup v-model="data.idcitycategory2" mode="right" width="70%">
			<view class="poplist poplist2">
				<scroll-view scroll-y="true" style="height: 100%;">
					<view class="botList" v-for="(item,index) in data.childrenlist" :key="index"
						:class="data.isId2 == item.value? 'active':''"
						@tap="leftClick2(item.value,item.children,item.label)">
						<text>{{item.label}}</text>
						<u-icon name="arrow-right" v-if="item.children.length>0"
							:color="data.isId2 == item.value? '#00D075':'#867F7F'" size="28"></u-icon>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		<u-popup v-model="data.idcitycategory3" mode="right" width="55%">
			<view class="poplist poplist2">
				<scroll-view scroll-y="true" style="height: 100%;">
					<view class="botList" v-for="(item,index) in data.childrenlist2" :key="index"
						:class="data.isId3 == item.value? 'active':''" @tap="leftClick3(item.value,item.label)">
						<text>{{item.label}}</text>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		<!-- 选择地区结束 -->
		<u-action-sheet :list="data.sheetList" cancel-text="取消" v-model="data.sheetShow" @close="data.sheetShow = false"
			@click="sheetClick">
		</u-action-sheet>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from "vue"
	import {
		onReady,
		onShow,
		onLoad
	} from '@dcloudio/uni-app'
	const form1 = ref();
	const form2 = ref();
	const data = reactive({
		numList: [{
			name: ' 填写基本信息'
		}, {
			name: '选择职位要求'
		}],
		current: 0,
		errorType: ['message'],
		rules: {
			"basic.jobname": [{
				required: true,
				message: '请输入职位名称',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.nature_text": [{
				required: true,
				message: '请选择招聘类型',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.content": [{
				required: true,
				message: '请填写职位描述',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.category_text": [{
				required: true,
				message: '请选择职位类型',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.experience_text": [{
				required: true,
				message: '请选择经验要求',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.education_text": [{
				required: true,
				message: '请选择最低学历',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.wage_text": [{
				required: true,
				message: '请选择薪资范围',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.age_text": [{
				required: true,
				message: '请选择年龄范围',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.department": [{
				required: true,
				message: '请填写部门',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.amount_text": [{
				required: true,
				message: '请填写招聘人数',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"basic.district_text": [{
				required: true,
				message: '请选择工作地区',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"contact.use_company_contact_text": [{
				required: true,
				message: '请选择联系方式',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"contact.contact": [{
				required: true,
				message: '请填写联系人',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}],
			"contact.mobile": [{
				required: true,
				message: '请填写联系电话',
				// 可以单个或者同时写两个触发验证方式 
				trigger: 'blur',
			}]

		},
		formData: {
			basic: {
				jobname: '', //职位名
				nature: null, //招聘类型
				nature_text: "",
				content: '', //职位描述
				category_text: '', //职位类别/行业/职位名
				tag_text: "",
				tag: [], //岗位福利
				experience_text: "", //经验要求
				experience: null,
				education: null, //学历
				education_text: "",
				minwage: 500, //最低薪资
				maxwage: 50000, //最高薪资
				wage_text: "",
				minage: 16, //最小年龄
				maxage: 65, //最大年龄
				age_text: "",
				age_na: 0, // 不限
				department: "",
				amount: 0,
				amount_text: "",
				district_text: "",
				district: null,
				district_text: "",
				district1: null,
				district2: null,
				district3: null
			},
			contact: {
				use_company_contact_text: "使用企业资料联系方式",
				use_company_contact: 1,
				contact: "",
				weixin: "",
				is_display: 1,
				mobile: "",
				telephone: "",
				email: "",
				qq: "",
				is_secrecy: 0
			},

		},
		confirmText: "下一步",
		StepsShow: false,
		topText: '发布职位',
		placeholderStyle: "color: #c0c4cc;width:600rpx;",
		isnature: false,
		natureList: [],
		experiencelist: [],
		defaultIndex: [0],
		defaultExp: [0],
		isexperience: false,
		educationlist: [],
		iseducation: false,
		defaultEdu: [0],
		// 期望薪资
		isWage: false,
		isage: false,
		citycategory: [],
		idcitycategory: false,
		idcitycategory2: false,
		idcitycategory3: false,
		isId: null,
		isId2: null,
		isId3: null,
		childrenlist: [],
		childrenlist2: [],
		checked: false,
		isuse_company_contact: false,
		sheetList: [{
			text: '使用企业联系方式',
			index: 0
		}, {
			text: '其他联系方式',
			index: 1
		}],
		sheetShow: true,
		isEdit: false
	})

	// 招聘类型确定事件
	const natureConfirm = (e) => {
		data.formData.basic.nature = data.natureList[e].id
		data.formData.basic.nature_text = data.natureList[e].name
		//再次点击回显
		let cur = data.natureList.findIndex(item => {
			return item.name == data.formData.basic.nature_text
		})
		if (cur != -1) {
			data.defaultIndex = [cur]
		}
	}

	const tocontent = () => {
		uni.$u.route(
			"pages/pagesPersonal/job/jobEdit/content", {
				content: data.formData.basic.content
			}
		)
	}
	const getfrist = () => {
		data.StepsShow = false
		data.confirmText = "下一步"
		data.current = 0

	}
	const tocategoryName = () => {
		uni.$u.route("pages/pagesPersonal/job/jobEdit/jobType", {
			isId: data.formData.basic.category1,
			isId2: data.formData.basic.category2,
			isId3: data.formData.basic.category3
		})
	}
	const tag = () => {
		uni.$u.route("pages/pagesPersonal/job/jobEdit/welfare", {
			item: encodeURIComponent(JSON.stringify(data.formData.basic.tag))
		})
	}

	const getShow = () => {
		data.idcitycategory = true
		if (data.isId2) {
			data.idcitycategory2 = true
		}
		if (data.isId3) {
			data.idcitycategory3 = true
		}
	}
	//详细地址点击事件
	const toaddress = () => {
		getUserLocation()
	}
	//选择详细地址
	const getUserLocation = () => {
		uni.chooseLocation({
			success: res => {
				data.formData.basic.map_lat = res.latitude
				data.formData.basic.map_lng = res.longitude
				data.formData.basic.address = res.address
			},
			fail: err => {}
		});
	}
	//经验要求确定事件
	const experienceConfirm = (e) => {
		data.formData.basic.experience_text = data.experiencelist[e].name
		data.formData.basic.experience = data.experiencelist[e].id
		let exindex = data.experiencelist.findIndex(item => {
			return item.name == data.formData.basic.experience_text
		})
		if (exindex != -1) {
			data.defaultExp = [exindex]
		}
	}
	//最低学历确定事件
	const educationConfirm = (e) => {
		data.formData.basic.education_text = data.educationlist[e].name
		data.formData.basic.education = data.educationlist[e].id
		let eduindex = data.educationlist.findIndex(item => {
			return item.name == data.formData.basic.education_text
		})
		if (eduindex != -1) {
			data.defaultEdu = [eduindex]
		}
	}
	// 薪资确定事件
	const wageConfirm = ({
		min,
		max
	}) => {
		data.formData.basic.minwage = min
		data.formData.basic.maxwage = max
		data.formData.basic.wage_text = `${min / 1000}K~${max/1000}K`
		data.isWage = false
	}
	//年龄确定事件
	const ageConfirm = ({
		min,
		max
	}) => {
		if (min == "不限") {
			data.formData.basic.age_text = "不限"
			data.formData.basic.age_na = 1
			data.formData.basic.minage = 0
			data.formData.basic.maxage = 0
		} else {
			data.formData.basic.minage = min
			data.formData.basic.maxage = max
			data.formData.basic.age_text = `${min}岁~${max}岁`
			data.formData.basic.age_na = 0
		}
		data.isage = false
	}

	const leftClick = (id, list, name) => {
		data.isId = id
		data.isId2 = 0
		data.isId3 = 0
		data.formData.basic.district_text = name
		data.formData.basic.district1 = id
		data.formData.basic.district2 = 0
		data.formData.basic.district3 = 0
		data.childrenlist2 = []
		data.childrenlist = list
		if (list.length > 0) {
			data.idcitycategory2 = true
		} else {
			data.idcitycategory = false
			data.idcitycategory2 = false
			data.idcitycategory3 = false
		}

	}
	const leftClick2 = (id, list, name) => {
		data.isId2 = id
		data.isId3 = 0
		data.childrenlist2 = list
		data.formData.basic.district_text = name
		data.formData.basic.district1 = data.isId
		data.formData.basic.district2 = id
		data.formData.basic.district3 = 0
		if (data.childrenlist2.length > 0) {
			data.idcitycategory3 = true
		} else {
			data.idcitycategory = false
			data.idcitycategory2 = false
			data.idcitycategory3 = false
		}
	}

	const leftClick3 = (id, name) => {
		data.isId3 = id
		data.formData.basic.district_text = name
		data.formData.basic.district1 = data.isId
		data.formData.basic.district2 = data.isId2
		data.formData.basic.district3 = id
		data.idcitycategory = false
		data.idcitycategory2 = false
		data.idcitycategory3 = false
	}

	const checked = (status) => {
		if (status) {
			data.formData.contact.is_secrecy = 1
		} else {
			data.formData.contact.is_secrecy = 0
		}
	}
	const sheetClick = (index) => {
		if (index == 0) {
			data.isuse_company_contact = false
			data.formData.contact.use_company_contact_text = "使用企业资料联系方式"
			data.formData.contact.use_company_contact = 1
		} else {
			data.isuse_company_contact = true
			data.formData.contact.use_company_contact_text = "使用其他联系方式"
			data.formData.contact.use_company_contact = 0
		}
	}

	const amountChange = (value) => {
		data.formData.basic.amount = parseFloat(value)
	}
	const submit = () => {
		form1.value.validate(async valid => {
			if (valid) {
				if (!data.StepsShow) {
					data.confirmText = "保存职位"
					data.topText = "继续填写"
					data.StepsShow = true
					data.current = 1
				} else {

					if (data.formData.contact.mobile && !uni.$u.test.mobile(data.formData.contact
							.mobile)) {
						return uni.showToast({
							title: '请填写正确的手机号',
							icon: "none"
						})
					}
					if (data.formData.contact.weixin && !uni.$u.test.mobile(data.formData.contact
							.weixin) && !uni.$u.test.wx(data.formData.contact.weixin)) {
						return uni.showToast({
							title: '请填写正确的微信号',
							icon: "none"
						})
					}
					if (data.formData.contact.telephone && !uni.$u.test.isMob(data.formData.contact
							.telephone)) {
						return uni.showToast({
							title: '请填写正确的联系固话',
							icon: "none"
						})
					}
					if (data.formData.contact.email && !uni.$u.test.email(data.formData.contact.email)) {
						return uni.showToast({
							title: '请填写正确的邮箱号',
							icon: "none"
						})
					}
					if (data.formData.contact.qq && !uni.$u.test.qq(data.formData.contact.qq)) {
						return uni.showToast({
							title: '请填写正确的QQ号',
							icon: "none"
						})
					}
					if (data.isEdit) { //修改
						let res = await uni.$u.api.editSave(data.formData)
						if (res) {
							uni.$u.toast('修改成功')
							setTimeout(() => {
								uni.$u.route({
									type: 'back'
								})
							}, 500)
						}
					} else { // 新增
						let res = await uni.$u.api.addSave(data.formData)
						if (res) {
							uni.$u.toast('添加成功')
							setTimeout(() => {
								uni.$u.route({
									type: 'back'
								})
							}, 500)
						}
					}

				}
			}
		});
	}
	// 获取字典表数据
	const getClassifyData = async () => {
		let params = {
			type: 'jobNature,experience,education,citycategory'
		}
		let res = await uni.$u.api.getClassifyInfo({
			params
		})
		if (res) {
			//招聘类型回显
			data.natureList = res.jobNature
			let cur = data.natureList.findIndex(item => {
				return item.name == data.formData.basic.nature_text
			})
			if (cur != -1) {
				data.defaultIndex = [cur]
			}
			// 经验要求回显
			data.experiencelist = res.experience
			let exindex = data.experiencelist.findIndex(item => {
				return item.name == data.formData.basic.experience_text
			})
			if (exindex != -1) {
				data.defaultExp = [exindex]
			}
			//最低学历回显
			data.educationlist = res.education
			let eduindex = data.educationlist.findIndex(item => {
				return item.name == data.formData.basic.education_text
			})
			if (eduindex != -1) {
				data.defaultEdu = [eduindex]
			}
			data.citycategory = res.citycategory
			if (data.isId) {
				let cur = res.citycategory.findIndex(item => {
					return item.value == data.isId
				})
				if (cur != -1) {
					data.childrenlist = res.citycategory[cur].children
					if (data.isId3 != 0) {
						let cur2 = data.childrenlist.findIndex(item => {
							return item.value == data.isId2
						})

						if (cur2 != -1) {
							data.childrenlist2 = data.childrenlist[cur2].children
						}
					}
				}
			}
		}
	}
	const editPre = async (id) => {
		let params = {
			id: id
		}
		let res = await uni.$u.api.editPre({
			params
		})
		if (res) {
			data.formData.basic = res.basic
			data.formData.contact = res.contact
			data.formData.basic.tag_text = res.basic.tag_text_arr.join(",")
			if (res.contact.use_company_contact == 1) {
				data.formData.contact.use_company_contact_text = "使用企业资料联系方式"
			} else {
				data.formData.contact.use_company_contact_text = "使用其他联系方式"
			}
			data.isId = res.basic.district1
			data.isId2 = res.basic.district2
			data.isId3 = res.basic.district3
			// 判断是否保密联系方式
			if (res.contact.is_secrecy == 0) {
				data.checked = false
			} else {
				data.checked = true
			}
		}
	}
	onLoad(async ({
		id
	}) => {
		if (id && id != undefined) {
			data.topText = "修改职位"
			let geteditPre = await editPre(id)
			data.isEdit = true
		}
		getClassifyData()
	})
	onShow(() => {
		let pages = getCurrentPages()
		if (pages.length == 2) {
			if (pages[1].$vm.content) { //职位描述
				data.formData.basic.content = pages[1].$vm.content
			}
			if (pages[1].$vm.category) { //职位类型
				data.formData.basic.category_text = pages[1].$vm.category.categoryName
				data.formData.basic.category1 = pages[1].$vm.category.category1
				data.formData.basic.category2 = pages[1].$vm.category.category2
				data.formData.basic.category3 = pages[1].$vm.category.category3
			}
			if (pages[1].$vm.tagdata) { //岗位福利
				data.formData.basic.tag = pages[1].$vm.tagdata.tag
				data.formData.basic.tag_text = pages[1].$vm.tagdata.tag_text_arr.join(",")
			}
		} else if (pages.length == 3) {
			if (pages[2].$vm.content) { //职位描述
				data.formData.basic.content = pages[2].$vm.content
			}
			if (pages[2].$vm.category) { //职位类型
				data.formData.basic.category_text = pages[2].$vm.category.categoryName
				data.formData.basic.category1 = pages[2].$vm.category.category1
				data.formData.basic.category2 = pages[2].$vm.category.category2
				data.formData.basic.category3 = pages[2].$vm.category.category3
			}
			if (pages[2].$vm.tagdata) { //岗位福利
				data.formData.basic.tag = pages[2].$vm.tagdata.tag
				data.formData.basic.tag_text = pages[2].$vm.tagdata.tag_text_arr.join(",")
			}
		}
	})
	onReady(() => {
		form1.value.setRules(data.rules)
	})
</script>
<style lang="scss" scoped>
	page,
	body {
		background-color: #fff;
	}

	.container {
		padding: 30rpx;

		.headerNav {}

		.Steps {
			.toptext {
				padding: 0 30rpx;
				font-size: 56rpx;
				font-weight: bold;
				font-family: SourceHanSansSC-medium;
				margin-bottom: 20rpx;
			}
		}

		.from {
			margin-bottom: 140rpx;
		}
	}

	.active {
		color: #00D075;
	}

	.poplist {
		padding: 30rpx;

		.botList {
			height: 120rpx;
			width: 100%;
			border-bottom: 1rpx solid #ccc;
			display: flex;
			justify-content: space-between;
			align-items: center;

			text {
				font-size: 28rpx;
				font-weight: bold;
			}
		}
	}

	.poplist2 {
		width: 100%;
		height: 70%;
		position: absolute;
		bottom: 0;
		background-color: #fff;
	}

	:deep .u-drawer-right {
		background-color: rgba(0, 0, 0, 0) !important;
	}

	:deep .u-field__input-wrap {
		width: 500rpx !important;
	}

	:deep .u-flex {
		margin: 0 !important;
	}
</style>